﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
//using Microhard.Weixin.MyBus.Interfaces;
//using Microhard.Weixin.MyBus.Impls;
using Microhard.WeixinMP.Unities;
using Microhard.WeixinMP.DTO;
//using Microhard.Weixin.MyBus.Models.Wuhan;

namespace TestProject
{
    [TestClass]
    public class GetBusInfo
    {
        [TestMethod]
        public void TestMethod1()
        {
            //WHDataOperator reader = new WHDataOperator(WHConst.MONGODB_DBNAME_WHBUS, WHConst.MONGODB_COLLNAME_RUNNINGINFO);
            //var bus = reader.GetFromCache("581");
            //IWHBus ib = new WHBusImpl();
            //var busNos = ib.GetAllBusNos();
            //ib.SaveAllBusRunningInfo(busNos);

            //WHDataOperator reader = new WHDataOperator("WHBUS", "RunningInfo");
            //var bus = reader.GetFromCache("1");

            //微信
            //WXModelMapper.InitMap();

            //IBusNotifiPlan ib = new BusPlanImplDB();
            //var data = ib.ToNotifiByUserPlan();
            //foreach (var p in data)
            //{
            //    //拼装消息
            //    var latestBus = p.BeforeMyStopRunningBusInfo.OrderByDescending(b => b.order).First();
            //    StringBuilder msg = new StringBuilder();
            //    msg.AppendLine(p.WeixinNickName + ",你好:");
            //    msg.Append("您订阅的公交线路:" + p.BusNo + ",从" + p.DirectionTxt);
            //    msg.Append("，已经有一辆公交车距离您所在的【" + p.AllStops.SingleOrDefault(s => s.stopId == p.MyStopID).stopName + "】");
            //    msg.AppendLine("还有【" + (p.MyStopOrder - latestBus.order) + "】站,请提前做好上车准备");
            //    msg.AppendLine("所有在途车辆运营明细如下:");
            //    foreach (var b in p.BeforeMyStopRunningBusInfo)
            //    {
            //        var stop = p.AllStops.SingleOrDefault(s => s.stopId == b.stopId);
            //        msg.AppendLine(stop.order + "." + stop.stopName + "(在途" + b.busNum + ")");
            //    }
            //    //微信发送
            //    WeixinTools.SendTextMessage(p.WXMPAccount, p.WXMPPWD, msg.ToString(), p.WeixinFakeID);
            //}
        }
    }
}
